﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _03_TakeATenMinutesWalk
{
    public class Kata
    {
        public static bool IsValidWalk(string[] walk)
        {
            //insert brilliant code here
            return (walk.Select(s => s == "e" || s == "w" || s == "s" || s == "n").ToList().IndexOf(false) < 0) && walk.Where(s => s == "e").Count() == walk.Where(s => s == "w").Count() && walk.Where(s => s == "s").Count() == walk.Where(s => s == "n").Count() && walk.Length == 10;
            //其他好的方案，使用Linq
            //return walk.Count(x => x == "n") == walk.Count(x => x == "s") && walk.Count(x => x == "e") == walk.Count(x => x == "w") && walk.Length == 10;
        }
    }
}
